﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using r4u.business.logic.layer.ALERT;
using r4u.business.logic.layer.REGISTER;

namespace r4u.Controllers
{
    public class VerifyController : Controller
    {
        //
        // GET: /Verify/

        public ActionResult Index()
        {
            return View();
        }


        public ActionResult GetContact()
        {
            User temp = new User();
            var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
            var jsonResult = new ContentResult
                {
                    Content = JsonConvert.SerializeObject(temp.GetContact(HttpContext.User.Identity.Name), settings),
                    ContentType = "application/json"
                };
            return jsonResult;
        }

        public ActionResult SendVerificationCode()
        {
            Mail temp = new Mail();
            if (temp.SendVerificationCode(HttpContext.User.Identity.Name))
            {
                return new HttpStatusCodeResult(HttpStatusCode.OK);
            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }
        }


        public ActionResult Activate(int id)
        {
            User temp = new User();
            if (temp.ActivateAccount(HttpContext.User.Identity.Name, id.ToString()))
            {
                return new HttpStatusCodeResult(HttpStatusCode.OK);
            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }
        }
    
    }
}
